﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace ExcelToChart
{
    public partial class Form_SelectYearMonth : Form
    {
        public DateTime dateTime  { get; set; }

        public Form_SelectYearMonth()
        {
            InitializeComponent();
        }

        public Form_SelectYearMonth(DateTime dt)
        {
            dateTime = dt;
            InitializeComponent();

            dateTimePicker_Year.Value = dt;
            dateTimePicker_Month.Value = dt;
            Console.WriteLine(dt);
        }

        private void button_OK_Click(object sender, EventArgs e)
        {
            this.DialogResult = DialogResult.OK;
            this.Close();
        }

        private void button_Cancel_Click(object sender, EventArgs e)
        {
            this.DialogResult = DialogResult.Cancel;
            this.Close();
        }

        private void dateTimePicker_Year_ValueChanged(object sender, EventArgs e)
        {
            int yyyy = dateTimePicker_Year.Value.Year;
            int MM = dateTimePicker_Month.Value.Month;
            dateTime = new DateTime(yyyy, MM, 1);
        }

        private void dateTimePicker_Month_ValueChanged(object sender, EventArgs e)
        {
            int yyyy = dateTimePicker_Year.Value.Year;
            int MM = dateTimePicker_Month.Value.Month;
            dateTime = new DateTime(yyyy, MM, 1);
        }
    }
}
